home *** CD-ROM | disk | FTP | other *** search
- Path: news.compuserve.com!newsmaster
- From: Philippe Verdy <100105.3120@compuserve.com>
- Newsgroups: comp.lang.c++
- Subject: Re: (no subject)
- Date: 1 Apr 1996 22:25:11 GMT
- Organization: CompuServe Incorporated
- Message-ID: <4jpl47$rjj@dub-news-svc-2.compuserve.com>
- NNTP-Posting-Host: dd07-044.compuserve.com
-
- Ravi Annavajjhala <rannavaj> s'Θcrit :
- > Hi,
- > I am using Borland C++ 4.52. I am trying to use templates
- > and if I do not code the functions for my templates "inline",
- > I am getting linker errors.
- >
- > Could someone please help .....
- > --
- > Ravi Annavajjhala
- > Intel Corporation
- > 1900 Prairie City Road
- > Folsom, CA 95630
- > rannavaj@mcd.intel.com
- > (916) 356 6491
- >
- You need to implement your template methods, using the template
- specificator. But you're partly right: this code may be outlined
- provided you keep it within your include files, else you won't be
- able to reuse the template library in your apps.
-
- Ex:
- template<class T>
- class X {
- X();
- virtual ~X();
- void method();
- static int member;
- }
-
- template <class T>
- X<T>::X()
- {
- ...
- }
-
- template <class T>
- X<T>::~X()
- {
- ...
- }
-
- template <class T>
- void X<T>::method()
- {
- ...
- }
-
- template <class T>
- int X<T>::member = 0;
-
- The main idea is here to prefix the template arguments
- on all your outline definitions, so that they can bind
- themselves to their appropriate template arguments and types.
-
-